package io.hxci.modules.edu.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.hxci.common.utils.PageUtils;
import io.hxci.common.utils.Query;
import io.hxci.modules.edu.dao.AttendanceMapper;
import io.hxci.modules.edu.domain.EduSign;
import io.hxci.modules.edu.service.AttendanceService;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, EduSign> implements AttendanceService {
    @Override
    public PageUtils query(Map<String, Object> params, Long userId) {
        IPage<EduSign> page = new Query<EduSign>().getPage(params);
        String cid = (String)params.get("cid");
        String bid = (String)params.get("bid");
        String sksj =(String)params.get("sksj");
        String date =(String)params.get("date");
        if( (cid == null ||cid.equals("")) &&(bid == null ||bid.equals(""))&&(sksj == null ||sksj.equals(""))&&(date == null ||date.equals("")) ){
            page.setRecords(null);
            return new   PageUtils(page);
        }else {
            List<EduSign> list =this.baseMapper.attendance(page,userId,cid,bid,sksj,date);
            page.setRecords(list);
            return new PageUtils(page);
        }

    }

    @Override
    public List<Map> coptions(Long userId) {
        return this.baseMapper.coptions(userId);
    }

    @Override
    public List<Map> boptions(Long userId) {
        return this.baseMapper.boptions(userId);
    }
}
